/**
 * 
 */
package org.rollinitiative.d20.entity.races;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;

import org.rollinitiative.d20.Adjustment;
import org.rollinitiative.d20.AdjustmentData;

/**
 * @author bebopjmm
 * 
 */
@Entity
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "RacialLevelType", namespace = "java:org.rollinitiative.d20.entity")
public class RacialLevel
{
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @XmlTransient
    private Long persistID;

    @XmlAttribute(required = true)
    private short level = 0;

    @XmlElement(name = "AdjustmentEntry")
    @OneToMany(cascade = CascadeType.ALL)
    private List<AdjustmentData> adjustmentData = new ArrayList<AdjustmentData>();

    @XmlTransient
    @Transient
    private List<Adjustment> adjustments = null;


    // @XmlElement(name = "SkillBonus")
    // private ArrayList<SkillTraining> skillList = new ArrayList<SkillTraining>();

    // private CombatSpec combatMods = new CombatSpec();

    public RacialLevel()
    {

    }


    public RacialLevel(short level)
    {
        this.level = level;
        // this.abilModifiers = abilityMods;
        // buildAbilityModifiers();
    }


    /**
     * @return the level
     */
    public short getLevel()
    {
        return level;
    }


    /**
     * @param level the level to set
     */
    public void setLevel(short level)
    {
        this.level = level;
    }

    // /**
    // * @return the combatMods
    // */
    // public CombatSpec getCombatMods()
    // {
    // return combatMods;
    // }
    //
    //
    // /**
    // * @param combatMods the combatMods to set
    // */
    // @XmlElement(name = "CombatMods", required = true)
    // public void setCombatMods(CombatSpec combatMods)
    // {
    // this.combatMods = combatMods;
    // }

    // /**
    // * @return the abilModChoice
    // */
    // public AbilityModifierChoice getAbilModChoice()
    // {
    // return abilModChoice;
    // }
    //
    //
    // /**
    // * @param abilModChoice the abilModChoice to set
    // */
    // @XmlElement(name = "AbilityModifierChoice", required = false)
    // public void setAbilModChoice(AbilityModifierChoice abilModChoice)
    // {
    // this.abilModChoice = abilModChoice;
    // }

    // public SkillTraining[] getSkillBonuses()
    // {
    // return skillList.toArray(new SkillTraining[skillList.size()]);
    // }

    /**
     * @return the adjustments
     */
    public List<AdjustmentData> getAdjustmentData()
    {
        return adjustmentData;
    }


    /**
     * @param adjustments the adjustments to set
     */
    public void setAdjustments(List<AdjustmentData> adjustmentData)
    {
        this.adjustmentData = adjustmentData;
    }


    /**
     * @return the adjustments
     */
    public List<Adjustment> getAdjustments()
    {
        if (adjustments == null) {
            adjustments = new ArrayList<Adjustment>(adjustmentData.size());
            for (AdjustmentData entry : adjustmentData) {
                adjustments.add(new Adjustment(entry));
            }
        }
        return adjustments;
    }


    public Long getPersistID()
    {
        return persistID;
    }


    public void setPersistID(Long persistID)
    {
        this.persistID = persistID;
    }

    // @XmlType(name = "RacialCombatType", namespace = "java:org.rollinitiative.d20.entity")
    // public static class CombatSpec
    // {
    // private int naturalArmor = 0;
    //
    // private int racialBAB = 0;
    //
    //
    // /**
    // * @return the naturalArmor
    // */
    // public int getNaturalArmor()
    // {
    // return naturalArmor;
    // }
    //
    //
    // /**
    // * @param naturalArmor the naturalArmor to set
    // */
    // @XmlAttribute(required = true)
    // public void setNaturalArmor(int naturalArmor)
    // {
    // this.naturalArmor = naturalArmor;
    // }
    //
    //
    // /**
    // * @return the racialBAB
    // */
    // public int getRacialBAB()
    // {
    // return racialBAB;
    // }
    //
    //
    // /**
    // * @param racialBAB the racialBAB to set
    // */
    // @XmlAttribute(required = true)
    // public void setRacialBAB(int racialBAB)
    // {
    // this.racialBAB = racialBAB;
    // }
    //
    // }

    // @XmlType(name = "AbilityModifierChoiceType", namespace =
    // "java:org.rollinitiative.d20.entity")
    // public static class AbilityModifierChoice
    // {
    // private int modifier = 0;
    //
    // private QName id;
    //
    //
    // /**
    // * @return the modifier
    // */
    // public int getModifier()
    // {
    // return modifier;
    // }
    //
    //
    // /**
    // * @param modifier the modifier to set
    // */
    // @XmlAttribute(name = "modifier", required = true)
    // public void setModifier(int modifier)
    // {
    // this.modifier = modifier;
    // }
    //
    //
    // /**
    // * @return the id
    // */
    // public QName getId()
    // {
    // return id;
    // }
    //
    //
    // /**
    // * @param id the id to set
    // */
    // @XmlAttribute(name = "id", required = true)
    // public void setId(QName id)
    // {
    // this.id = id;
    // }
    //
    // }
}
